#pragma once
#include <mutex>
#include <condition_variable>
#include <queue>

template <typename T>
class LockQueue
{
public:
    T pop()
    {
        std::unique_lock<std::mutex> lock(mtx_);
        while (queue_.empty())
        {
            cond_.wait(lock);
        }

        T data = queue_.front();
        queue_.pop();
        return data;
    }
    void push(const T &data)
    {
        std::lock_guard<std::mutex> lock(mtx_);
        queue_.push(data);
        cond_.notify_one();
    }

private:
    std::queue<T> queue_;
    std::mutex mtx_;
    std::condition_variable cond_;
};